﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Windows.Forms.Design;

namespace FdControlls.Fonts
{
    public class ScopeDropDownEditor : UITypeEditor
    {
       
        IWindowsFormsEditorService editorService = null;

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null && context.Instance != null)
            {
                return UITypeEditorEditStyle.DropDown;
            }
            return base.GetEditStyle(context);
        }
        public override object EditValue(ITypeDescriptorContext context,IServiceProvider provider, object value)
        {

            if (context != null && context.Instance != null && provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    ScopeEditorControl editorControl =new ScopeEditorControl(EIconType.ICON_104, close1);
                    editorService.DropDownControl(editorControl);
                    value = editorControl.Scope; editorService.CloseDropDown();
                    return value;
                }
            }
            return value;
        }

        private void close1()
        {
            editorService.CloseDropDown();
        }
    }
}
